package de.lns.entities.effect;

import java.util.ArrayList;

import de.lns.entities.Entity;
import de.lns.level.Level;
/**
 * 
 * @author Jascha
 *
 */
public abstract class Effect {
	protected Effectable entity;
	
	/**
	 * 
	 * @param entity The entity this effect should be applied to.
	 */
	
	public Effect(Effectable e) {
		this.entity = e;	
	}
	
	
//	/**
//	 * 
//	 * @return The entity this effect is applied to.
//	 */
//	public Effectable getEntity() {
//		return entity;
//	}
//	/**
//	 * 
//	 * @param entity The entity this effect should be applied to.
//	 */
//	public void setEntity(Effectable entity) {
//	}
	
	/**
	 * Fill this with content that should happen to your entity when this effect is triggered.
	 */
	public abstract void update();
	
	public Effectable getEntity() {
		return entity;
	}


	public void setEntity(Effectable entity) {
		this.entity = entity;
	}


	/**
	 * Just a static Method that is used to check range with circles.
	 * @param x The Xposition of the Center.
	 * @param y The Yposition of the Center.
	 * @param range The radius of the range cirlce.
	 * @return A Arraylist of all Entities that are in range.
	 */
	public static ArrayList<Entity> inrange(double x, double y, double range) {
		ArrayList<Entity> rangeEntity = new ArrayList<Entity>();
		for (Entity i : Level.getEntityList()) {
			double eX = i.getPosX()-x;
			double eY = i.getPosY()-y;
			if (Math.sqrt(eX * eX + eY * eY) < range
					&& Math.sqrt((eX * eX) + (eY * eY)) > -range) {
				rangeEntity.add(i);

			}
		}
		return rangeEntity;

	}

}
